﻿using CommandLine;
using System;
using System.Collections.Generic;
using System.Text;

namespace Model
{
    [ObjectEvent]
    public class OptionComponentEvent : ObjectEvent<OptionComponent>, IAwake<string[]>
    {
        public void Awake(string[] p1)
        {
            this.Get().Awake(p1);
        }
    }


    public class OptionComponent : Component
    {
        public Options Options { get; set; }
        public void Awake(string[] args)
        {
            Parser.Default.ParseArguments<Options>(args).WithNotParsed(err =>
            {
                throw new Exception("命令行格式错误！");
            }).WithParsed(options =>
            {
                Options = options;
            });
        }
    }
}
